{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7bfc1137-e213-44bb-8f0f-c17dd8722d2f",
   "metadata": {},
   "source": [
    "# Lag Plot\n",
    "\n",
    "Lag plots help reveal autocorrelation in time series data by comparing each observation with a lagged version of itself. In this example, we use a synthetic sine wave signal with added noise to illustrate the concept."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "392091e6-5e93-4560-bbcb-df6aac53d2d9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import hvplot.pandas  # noqa\n",
    "\n",
    "np.random.seed(1)\n",
    "t = pd.date_range(\"2025-01-01\", periods=200)\n",
    "data = pd.Series(np.sin(np.linspace(0, 20, 200)) + np.random.normal(0, 0.2, 200), index=t)\n",
    "\n",
    "hvplot.plotting.lag_plot(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d5f0cbc9-c351-4225-8305-29c1b95f8563",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import hvplot.pandas  # noqa\n",
    "hvplot.extension(\"matplotlib\")\n",
    "\n",
    "np.random.seed(1)\n",
    "t = pd.date_range(\"2025-01-01\", periods=200)\n",
    "data = pd.Series(np.sin(np.linspace(0, 20, 200)) + np.random.normal(0, 0.2, 200), index=t)\n",
    "\n",
    "hvplot.plotting.lag_plot(data)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bf8da157-81c7-420c-b96f-fc8c16835aad",
   "metadata": {},
   "source": [
    ":::{seealso}\n",
    "- [Lag Plots reference documentation](../../ref/api/manual/hvplot.plotting.lag_plot.ipynb).\n",
    ":::"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
